package com.cn.dao;
/**
 * 短租车辆信息实体类
 */
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.cn.add.entity.Odercar_entity;
import com.cn.conn.DataManager;
import com.cn.conn.RowDatas;

public class dz_chexing_dao extends DataManager{
	private RowDatas<Odercar_entity> odercar;
	
	public dz_chexing_dao(){
		odercar = new Odercar();
	}
	
	public List<Odercar_entity> getcar(String sqlson){
		if(sqlson==null){
			sqlson="and 1=1";
		}
		String sql="SELECT a.id,a.hot,a.new,a.tianchuang,a.lease_expense,"
				+ " b.brand,"
				+ " c.car_type,"
				+ " d.lablexiang,d.lablequdon,d.seating,"
				+ " e.address"
				+ " FROM tb_car a "
				+ " LEFT JOIN tb_carbrand b ON a.brand = b.id"
				+ " LEFT JOIN tb_cartype c  ON a.motorcycle_type = c.id"
				+ " LEFT JOIN tb_carconfigure d ON a.configuration_information = d.id"
				+ " LEFT JOIN tb_carimg e ON a.img = e.id"
				+ " WHERE 1=1 "+sqlson+"";
		
				return  queryList(sql, odercar);
		
	}
		
	private class Odercar implements RowDatas<Odercar_entity>{

		@Override
		public Odercar_entity getRowData(ResultSet rs) throws SQLException {
			Odercar_entity odercar=new  Odercar_entity();
			odercar.setAddress(rs.getString("address"));
			odercar.setBrand(rs.getString("brand"));
			odercar.setCar_type(rs.getString("car_type"));
			odercar.setLease_expense(rs.getInt("lease_expense"));
			odercar.setHot(rs.getInt("hot"));
			odercar.setNew_(rs.getInt("new"));
			odercar.setTianchuang(rs.getInt("tianchuang"));
			odercar.setSeating(rs.getInt("seating"));
			odercar.setLablequandon(rs.getString("lablequdon"));
			odercar.setLablexiang(rs.getString("lablexiang"));
			odercar.setId(rs.getInt("id"));
			
			return odercar;
		}
		
	}
	
}
